﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPF淡入淡出
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        int index = 1;
        private async void SwitchButton_Click(object sender, RoutedEventArgs e)
        {
            // 播放滑出动画
            (Resources["LeftSlideOut"] as Storyboard).Begin();
            (Resources["RightSlideOut"] as Storyboard).Begin();

            // 等待1秒
            await Task.Delay(300);

            // 切换右侧内容
            RightContent.Content = new TextBlock { Text = "新内容"+ index++, FontSize = 30 };

            // 播放滑入动画
            (Resources["LeftSlideIn"] as Storyboard).Begin();
            (Resources["RightSlideIn"] as Storyboard).Begin();
        }
    }
}